package boot

import (
	"gino/config"
	"gino/global"
	"gopkg.in/yaml.v2"
	"io/ioutil"
)

const configFile = "config.yaml"

func Config() {
	var c config.Config

	yamlFile, err := ioutil.ReadFile(configFile)
	if err != nil {
		panic("Failed to load yaml configuration file")
	}

	err = yaml.Unmarshal(yamlFile, &c)
	if err != nil {
		panic("Failed to unmarshal yaml configuration file")
	}

	global.Config = &c
}
